package contegor.scire.core;


/**
 * Default IdFragment.
 *
 * @version $Revision: 1.4 $
 * @author Héctor Cirbián Pousa
 */
public final class StringIdFragment implements IdFragment {
  private static final long serialVersionUID = -6814653673880831841L;

  private String name;
  
  public StringIdFragment(String name) {
    this.name = name;
  }

  @Override
  public boolean equals(Object obj) {
    if (this == obj)
      return true;
    if (!(obj instanceof StringIdFragment))
      return false;
    String rhs = ((StringIdFragment)obj).name;
    return (this.name == rhs) || this.name.equals(rhs);
  }

  public int compareTo(IdFragment obj) {
    if (this == obj)
      return 0;
    return this.name.compareTo(obj.toString());
  }

  @Override
  public int hashCode() {
    int aux = this.name.hashCode();
    return aux;
  }

  @Override
  public String toString() {
    return this.name;
  }
}
